/*
 * @Author: gyc
 * @Date: 2020-06-19 13:39:06
 * @LastEditTime: 2020-06-22 10:25:55
 * @Description: Nuxt测试版
 */
'use strict';

module.exports = app => {
  class Controller extends app.Controller {
    async index() {
      // const user = this.ctx.socket.handshake.query.userid;
      const message = this.ctx.args[0];
      console.log('chat :', message + ' : ' + process.pid);
      // const say = await this.ctx.service.user.say();
      this.ctx.socket.emit('res', process.pid);
      //用户存入redis
      // const iuser = await app.redis.get(user)
      // if (iuser) {
      //   console.log('用户已存在！')
      //   console.log(iuser)
      //   await app.io.of('/').adapter.remoteDisconnect(iuser, true, err => {
      //     console.log(err)
      //   });
      // } else {
      //   await app.redis.set(user, this.ctx.socket.id)
      // }

      // console.log(app.io.sockets.sockets)
    }
  }
  return Controller;
};